import { MigrationInterface, QueryRunner } from 'typeorm';

export class InitialSchema implements MigrationInterface {
  async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      CREATE TABLE session (
        id VARCHAR PRIMARY KEY,
        participants TEXT,
        agentId VARCHAR,
        createdAt DATETIME,
        updatedAt DATETIME
      )
    `);
    await queryRunner.query(`
      CREATE TABLE message (
        id VARCHAR PRIMARY KEY,
        sessionId VARCHAR,
        senderId VARCHAR,
        content TEXT,
        timestamp DATETIME
      )
    `);
    await queryRunner.query(`
      CREATE TABLE user (
        id VARCHAR PRIMARY KEY,
        username VARCHAR,
        status VARCHAR
      )
    `);
  }

  async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('DROP TABLE session');
    await queryRunner.query('DROP TABLE message');
    await queryRunner.query('DROP TABLE user');
  }
}
